﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebFormGlobus.aspx.cs" Inherits="WorldLocations.WebFormGlobus" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="formMain" runat="server">
    <asp:dropdownlist ID="DropdownlistContinents" runat="server" AutoPostBack="true"
        DataSourceID="EDSContinents" DataTextField="ContinentName" 
        DataValueField="ContinentID">
    </asp:dropdownlist>

    <asp:EntityDataSource ID="EDSContinents" runat="server" 
        ConnectionString="name=WorldLocationsEntities" 
        DefaultContainerName="WorldLocationsEntities" EnableFlattening="False" 
        EntitySetName="Continents">
    </asp:EntityDataSource>

    <asp:GridView ID="GridViewCountries" runat="server" AutoGenerateColumns="False" DataKeyNames="CountryID"
        DataSourceID="EDSCountries" AllowSorting="True"
        AutoGenerateDeleteButton="True" AutoGenerateEditButton="True" 
        AllowPaging="True">
        <Columns>
            <asp:CommandField ShowSelectButton="True" />            
            <asp:TemplateField SortExpression="CountryName">
            <HeaderTemplate><div>Country Name</div></HeaderTemplate>
            <ItemTemplate>
            <div><%# Eval("CountryName") + " "%></div>
            </ItemTemplate>            
            </asp:TemplateField>          
        </Columns>
    </asp:GridView>

    <asp:EntityDataSource ID="EDSCountries" runat="server" 
       
        ConnectionString="name=WorldLocationsEntities" 
        DefaultContainerName="WorldLocationsEntities" EnableFlattening="False" 
        EntitySetName="Countries" Select="it.[CountryName], it.[CountryID]"
        Where="it.[ContinentID]==@contID" EntityTypeFilter="" 
        OrderBy="it.[CountryName]">
        <WhereParameters>
            <asp:ControlParameter Type="Int32" ControlID="DropdownlistContinents"
             Name="contID" />
        </WhereParameters>
    </asp:EntityDataSource>

    <asp:ListView ID="ListViewCities" runat="server" DataSourceID="EDSCities">
    <LayoutTemplate>
        <h3>Cities</h3>
        <asp:PlaceHolder runat="server" ID="itemPlaceHolder"></asp:PlaceHolder>
    </LayoutTemplate>
    <ItemTemplate>
        <div>
            <%#Eval("CityName")%>
        </div>
    </ItemTemplate>
    </asp:ListView>

    <asp:EntityDataSource ID="EDSCities" runat="server" 
        ConnectionString="name=WorldLocationsEntities" 
        DefaultContainerName="WorldLocationsEntities"
        EntitySetName="Cities" Select="it.[CityName]" Where="it.[CountryID]==@ctrID">
        <WhereParameters>
        <asp:ControlParameter Type="Int32" ControlID="GridViewCountries" Name="ctrID"/>
        </WhereParameters>
    </asp:EntityDataSource>
    </form>
</body>
</html>

